package com.ytjj.qmyx.mall.client;

import com.alibaba.fastjson.JSONObject;
import com.alipay.api.request.AlipayMerchantOrderSyncRequest;
import com.alipay.api.response.*;
import com.ytjj.common.api.CommonResult;
import com.ytjj.common.enums.CounponMoneyEnum;
import com.ytjj.common.model.request.AliPayOrderSyncRequest;
import com.ytjj.qmyx.mall.model.*;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

@FeignClient("ygyx-mall")
public interface MallClient {

    @PostMapping("/order/updateOrdersPay")
    void updateOrdersPay(@RequestBody Map<String, String> map);

    @PostMapping("/order/updateAliPayOrdersPay")
    void updateAliPayOrdersPay(@RequestBody AlipayTradeQueryResponse response);

    @GetMapping("/common/getSysConfigValue")
    String getSysConfigValue(@RequestParam("key") String key);

    @GetMapping("/order/getPayConfigByCompany")
    PayConfigDto getPayConfigByCompany(@RequestParam("company") String Company);

    /**
     * 微信支付单号付款状态查询
     */
    @GetMapping("/order/wxAppOrderQuery")
    Map<String, String> wxAppOrderQuery(@RequestParam("resOrderNo") String resOrderNo,
                                        @RequestParam("tradeType") String tradeType);

    @GetMapping("/order/refundOrders")
    Map<String, String> refundOrders(@RequestParam("tradeType") String tradeType,
                                     @RequestParam("tradeNo") String tradeNo,
                                     @RequestParam("refundNo") String refundNo,
                                     @RequestParam("totalFee") Integer totalFee,
                                     @RequestParam("refundFee") Integer refundFee,
                                     @RequestParam("desc") String desc);

    @GetMapping("/order/h5RefundOrders")
    Map<String, String> h5RefundOrders(@RequestParam("tradeType") String tradeType,
                                       @RequestParam("tradeNo") String tradeNo,
                                       @RequestParam("refundNo") String refundNo,
                                       @RequestParam("totalFee") Integer totalFee,
                                       @RequestParam("refundFee") Integer refundFee,
                                       @RequestParam("desc") String desc);

    @GetMapping("/order/upayRefund")
    int upayRefund(@RequestParam("transactionId")String transactionId,@RequestParam("refundNo")String refundNo,@RequestParam("amount")String amount);

    @GetMapping("/order/zsyRefund")
    int zsyRefund(@RequestParam("mchOrderNo")String mchOrderNo,@RequestParam("refundNo")String refundNo,@RequestParam("amount")String amount,@RequestParam("payTime")String payTime);

    @GetMapping("/order/mhkjRefund")
    String mhkjRefund(@RequestParam("mchOrderNo")String mchOrderNo,@RequestParam("refundNo")String refundNo,@RequestParam("amount")String amount,@RequestParam("payTime")String payTime);

    @GetMapping("/order/mhkjRefundCj")
    String mhkjRefundCj(@RequestParam("mchOrderNo")String mchOrderNo,@RequestParam("refundNo")String refundNo,@RequestParam("amount")String amount,@RequestParam("payTime")String payTime);

    @GetMapping("/common/reflushCash")
    void reflushCash();

    @GetMapping("/common/getSysConfig")
    String getSysConfig(@RequestParam("key") String key);

    @GetMapping("/common/reflushChannelRedirect")
    void reflushChannelRedirect();

    @GetMapping("/dynamic/getDynamicById")
    DynamicDto getDynamicById(@RequestParam("dynamicId") Integer dynamicId);

    @GetMapping("/dynamic/getDynamicCountByUserId")
    DynamicDto getDynamicCountByUserId(@RequestParam("userId") Integer userId, @RequestParam("status") Integer status);

    @GetMapping("/order/queryCountByTel")
    Integer queryCountByTel(@RequestParam("tel") String tel);

    @GetMapping("/order/queryCountByTelRpc")
    DynamicDto queryCountByTelRpc(@RequestParam("tel") String tel);

    @GetMapping("/common/getCounponMoney")
    CommonResult getCounponMoney(@RequestParam(value = "type") CounponMoneyEnum type, @RequestParam(required = false) Integer userId);

    /**
     * 0元测评审核通过返本金
     * @param type
     * @param userId
     * @param money
     * @return
     */
    @GetMapping("/common/backZeroEvaluationCapitalMoney")
    CommonResult backZeroEvaluationCapitalMoney(@RequestParam(value = "type") CounponMoneyEnum type,
                                 @RequestParam(required = false) Integer userId,
                                 @RequestParam(value = "money") BigDecimal money);

    @GetMapping("/transfer/wxTransfer")
    CommonResult wxTransfer(@RequestParam("partnerTradeNo") String partnerTradeNo,
                            @RequestParam("openid") String openid,
                            @RequestParam("amount") String amount,
                            @RequestParam("desc") String desc);

    @PostMapping("/phoneRecharge/recharge")
    CommonResult recharge(@RequestBody RechargeRequest rechargeRequest);

    @PostMapping("/phoneRecharge/returnPhoneRecharge")
    CommonResult returnPhoneRecharge(@RequestBody ReturnPhoneRechargeRequest request);

    @PostMapping("/app/data/userRegister")
    CommonResult userRegister(@RequestBody UserRegisterRequestDto userRegisterRequest);

    @GetMapping("/order/ordersUpload")
    CommonResult ordersUpload(@RequestParam Integer orderId);

    @GetMapping("/order/toTransferOrders")
    CommonResult toTransferOrders(@RequestParam("orderId") Integer orderId,@RequestParam("transferId") Integer transferId);

    @PostMapping("/advertCb/sendEffectData")
    CommonResult sendEffectData(@RequestBody EffectParamRequest request);

    /**
     * 同步支付宝订单信息
     * @param request
     * @return
     * @throws Exception
     */
    @PostMapping("/alipay/syncAliPayOrder")
    AlipayMerchantOrderSyncResponse syncAliPayOrder(@RequestBody AliPayOrderSyncRequest request) throws Exception;

    /**
     * 查询投诉单协商历史
     */
    @GetMapping("/complaints/wxComplaintsV3History")
     CommonResult<List<ComplaintsHistoryResponse>> wxComplaintsV3History(@RequestParam String complaintId) throws Exception;

    /**
     * 回复用户
     * @param replyRequest
     * @return
     * @throws Exception
     */
    @PostMapping("/complaints/wxComplaintsV3Response")
     CommonResult wxComplaintsV3Response(@RequestBody WxComplaintsReplyRequest replyRequest) throws Exception;

    /**
     * 反馈处理完成
     * @param complaintId
     * @return
     * @throws Exception
     */
    @GetMapping("/complaints/wxComplaintsV3Complete")
    CommonResult<JSONObject> wxComplaintsV3Complete(@RequestParam("complaintId") String complaintId,@RequestParam("adminId") Integer adminId);

    /**
     * 投诉上传图片
     */
    @PostMapping("/complaints/upload")
     CommonResult<String> getImgUrl(@RequestParam("fileUrl") String  fileUrl,@RequestParam("complaintId") String complaintId) throws Exception;

    /**
     * 支付宝投诉回复
     */
    @PostMapping("/aliPayComplaints/complaintsReplySubmit")
     CommonResult<AlipayMerchantTradecomplainReplySubmitResponse> complaintsReplySubmit(@RequestBody AliPayComplatintsReplyRequest replyRequest) throws Exception;

    /**
     * 支付宝投诉商户上传反馈图片
     * @param imageUrl
     * @param complaintId
     * @return
     * @throws Exception
     */
    @PostMapping("/aliPayComplaints/uploadAliPayComplaintsImage")
     CommonResult<String> uploadAliPayComplaintsImage(@RequestParam("imageUrl") String  imageUrl, @RequestParam("complaintId") String complaintId);

    /**
     * 支付宝投诉反馈处理完成
     * @param feedbackRequest
     * @return
     * @throws Exception
     */
    @PostMapping("/aliPayComplaints/complaintsFeedbackSubmit")
     CommonResult<AlipayMerchantTradecomplainFeedbackSubmitResponse> complaintsFeedbackSubmit(@RequestBody AliPayComplatintsFeedbackRequest feedbackRequest);

    /**
     * 支付宝投诉查看详情
     * @param complainEventId
     * @return
     * @throws Exception
     */
    @GetMapping("/aliPayComplaints/queryAliPayComplaintsDetail")
    CommonResult<AlipayMerchantTradecomplainQueryResponse> queryAliPayComplaintsDetail(@RequestParam(value = "complainEventId") String complainEventId,
                                                                                       @RequestParam(value = "childId",required = false) String childId) throws Exception;


    /**
     * 商家补充凭证
     * @param supplementRequest
     * @return
     * @throws Exception
     */
    @PostMapping("/aliPayComplaints/complaintsSupplementSubmit")
    CommonResult<AlipayMerchantTradecomplainSupplementSubmitResponse > complaintsSupplementSubmit(@RequestBody AliPayComplatintsSupplementRequest supplementRequest);

    @GetMapping("/order/zsyRefundCJ")
    int zsyRefundCJ(@RequestParam(value = "mchOrderNo")String mchOrderNo,@RequestParam(value = "refundNo")String refundNo,@RequestParam(value = "amount")String amount,@RequestParam(value = "payTime")String payTime);
}
